package com.github.wxiaoqi.security.crm.core.api;

import java.util.Map;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.wxiaoqi.security.common.crm.request.AccountQueryRequest;
import com.github.wxiaoqi.security.common.crm.request.QueryFireSourceParam;
import com.github.wxiaoqi.security.common.msg.ResponseCode;
import com.github.wxiaoqi.security.common.util.EntityUtils;
import com.github.wxiaoqi.security.common.util.ResponseHelper;
import com.github.wxiaoqi.security.crm.core.biz.CommonAccountQueryBiz;
import com.github.wxiaoqi.security.crm.core.biz.PlatformUniqueCustomerBiz;
import com.github.wxiaoqi.security.crm.core.entity.PlatformUniqueCustomer;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags="账户管理")
@Controller
@RequestMapping("account")
public class AccountController {
	
	@Autowired
	private PlatformUniqueCustomerBiz platformUniqueCustomerBiz;
	@Autowired
	private CommonAccountQueryBiz commonAccountQueryBiz;
	
	/**
	 * 微信小程序火源账户信息查询
	 * @return
	 * @throws Exception 
	 */ 
	@ApiOperation("微信小程序火源账户信息查询")
	@RequestMapping(value = "/queryFireSourceInfo",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> queryFireSourceInfo(@RequestBody @Valid QueryFireSourceParam queryFireSourceParam) throws Exception {
		PlatformUniqueCustomer platformUniqueCustomer = platformUniqueCustomerBiz.wechatMiniFireSourceInfo(EntityUtils.beanToMap(queryFireSourceParam));
		return ResponseHelper.success(platformUniqueCustomer, null, ResponseCode.OK.getCode(), ResponseCode.OK.getMessage());
    }
	
	/**
	 * 账户查询
	 * @param 
	 * @return withdrawApply
	 */
	@ApiOperation("账户查询")
	@RequestMapping(value = "/accountQuery",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> accountQuery(@RequestBody @Valid AccountQueryRequest accountQueryRequest){
		Map<String, Object> response = commonAccountQueryBiz.accountQuery(accountQueryRequest);
		return response;
    }

}
